home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Games / Chess / Source / Clock.m < prev    next >
Text File  |  1994-04-01  |  891b  |  53 lines

  1. #import <appkit/appkit.h>
  2. #import "Clock.h"
  3.  
  4. static renderHand(float col,float len,int minute)
  5. {
  6.     PSgsave();
  7.     PSsetgray(col);
  8.     PStranslate(31.0,32.0);
  9.     PSrotate(-6.0*minute);
  10.     PSmoveto(0.0,0.0);
  11.     PSrlineto(0.0,len);
  12.     PSstroke();
  13.     PSgrestore();
  14.     return;
  15. }
  16.  
  17. @implementation  Clock
  18.  
  19. + newFrame:(NXRect const *)theFrame
  20. {
  21.   NXRect f;
  22.   
  23.   f = *theFrame;
  24.   f.size.width = 64.0;
  25.   f.size.height = 64.0;
  26.   self = [super newFrame: &f];
  27.   background = [Bitmap findBitmapFor: "clock"];
  28.   
  29.   return self;
  30. }
  31.  
  32. - setSeconds:(int)s { seconds = s; }
  33. - (int)getSeconds { return seconds; }
  34.  
  35. - drawSelf:(NXRect *)rects :(int)rectCount
  36. {
  37.   NXPoint p;
  38.   
  39.   p.x = p.y = 0.0;
  40.   PSgsave();
  41.   [background composite: NX_COPY toPoint: &p];
  42.   renderHand(0.333,20.0,seconds%60);
  43.   renderHand(0.0,20.0,seconds/60);
  44.   renderHand(0.,16.,seconds/3600);
  45.   PSgrestore();
  46.   
  47.   return self;
  48. }
  49.  
  50. @end
  51.  
  52.  
  53.